<?php

use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateGoodsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('cate_id')->comment('商品分类id');
            $table->string('goods_name', 150)->default('')->comment('商品名称');
            $table->string('goods_brief', 150)->default('')->comment('商品简介');
            $table->string('goods_img', 150)->default('')->comment('商品图片');
            $table->string('goods_thumb', 150)->default('')->comment('商品缩略图');
            $table->decimal('goods_price', 10,2)->default('0.00')->comment('商品价格');
            $table->integer('goods_salenum')->default(0)->comment('商品销量');
            $table->integer('goods_num')->default(0)->comment('商品数量');
            $table->tinyInteger('is_sale')->default(0)->comment('是否上架 0下架，1 上架');
            $table->text('goods_desc')->default('')->comment('商品详情');
            $table->text('goods_spec')->default('')->comment('商品规格参数');
            $table->dateTime('goods_addtime')->comment('添加商品时间');
            $table->dateTime('goods_saletime')->nullable()->comment('上架时间');
            $table->tinyInteger('goods_status')->default(1)->comment('商品状态 1正常 -1删除');
            $table->index(['goods_status', 'is_sale'], 'status');
            $table->index('cate_id');
            $table->index('goods_price');
            $table->index('goods_salenum');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::drop('goods');
    }
}
